package com.ziroom.crm.mq.rabbit.spring.wrapper;

import com.ziroom.crm.mq.core.MqType;
import com.ziroom.crm.mq.core.processor.QueueWrapper;

import java.util.Optional;

/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期         修改人          修改内容
 * </PRE>
 *
 * @author WeiShaoying
 * @version 1.0
 * @date Created in 2020年09月07日 14:20
 * @since 1.0
 */
public class RabbitConsumeQueueWrapper extends QueueWrapper {

    /**
     * 队列名称
     */
    private final String queueName;

    public RabbitConsumeQueueWrapper(MqType mqType, String queueName) {
        super(resolveName(mqType, queueName), mqType);
        this.queueName = queueName;
    }

    public String getQueueName() {
        return queueName;
    }

    /**
     * 解析name标记
     * RABBIT+队列名
     *
     * @param mqType    类型
     * @param queueName 队列名称
     * @return
     */
    private static String resolveName(MqType mqType, String queueName) {
        StringBuilder builder = new StringBuilder();
        builder.append(mqType.name());
        Optional.ofNullable(queueName).ifPresent(builder::append);
        return builder.toString();
    }

}
